<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>SemOpt: src/Grounded.cpp Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>


</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">SemOpt
   &#160;<span id="projectnumber">0.2alpha5-SCC</span>
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.6.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('Grounded_8cpp.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">src/Grounded.cpp</div>  </div>
</div><!--header-->
<div class="contents">
<a href="Grounded_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 
<a name="l00015"></a>00015 <span class="preprocessor">#include &quot;Grounded.h&quot;</span>
<a name="l00016"></a>00016 
<a name="l00046"></a><a class="code" href="classGrounded.html#a7825cea0732284e135768d4d25283b42">00046</a> <span class="keywordtype">void</span> <a class="code" href="classGrounded.html#a7825cea0732284e135768d4d25283b42" title="Computes the Grounded Algorithm.">Grounded::doGrounded</a>(<a class="code" href="classSetArguments.html" title="Class encompassing a set of arguments.">SetArguments</a> G, <a class="code" href="classSetArguments.html" title="Class encompassing a set of arguments.">SetArguments</a> C, <a class="code" href="classSetArguments.html" title="Class encompassing a set of arguments.">SetArguments</a>* e, <a class="code" href="classSetArguments.html" title="Class encompassing a set of arguments.">SetArguments</a>* I){
<a name="l00047"></a>00047 
<a name="l00048"></a>00048         *e = <a class="code" href="classSetArguments.html" title="Class encompassing a set of arguments.">SetArguments</a>();
<a name="l00049"></a>00049         *I = G;
<a name="l00050"></a>00050 
<a name="l00051"></a>00051         <a class="code" href="classSetArguments.html" title="Class encompassing a set of arguments.">SetArguments</a> N = <a class="code" href="classSetArguments.html" title="Class encompassing a set of arguments.">SetArguments</a>();
<a name="l00052"></a>00052         <a class="code" href="classSetArguments.html" title="Class encompassing a set of arguments.">SetArguments</a>* ANC;
<a name="l00053"></a>00053         <a class="code" href="classSetArguments.html" title="Class encompassing a set of arguments.">SetArguments</a>* ANI;
<a name="l00054"></a>00054         <a class="code" href="classSetArguments.html" title="Class encompassing a set of arguments.">SetArguments</a> Cunion;
<a name="l00055"></a>00055         <a class="code" href="classSetArguments.html" title="Class encompassing a set of arguments.">SetArguments</a> Iunion;
<a name="l00056"></a>00056 
<a name="l00057"></a>00057         <span class="keywordflow">while</span> (!<a class="code" href="classGrounded.html#a20b4011b5fa1a6f423708f8d293b7630" title="computes N and verify that it is empty">isNempty</a>(&amp;C, I, &amp;N)) {
<a name="l00058"></a>00058 
<a name="l00059"></a>00059                 Cunion = <a class="code" href="classSetArguments.html" title="Class encompassing a set of arguments.">SetArguments</a>();
<a name="l00060"></a>00060                 Iunion = <a class="code" href="classSetArguments.html" title="Class encompassing a set of arguments.">SetArguments</a>();
<a name="l00061"></a>00061 
<a name="l00062"></a>00062                 e-&gt;<a class="code" href="classSetArguments.html#a1b532abb70dde9aa99148be16ed59af1" title="Perform the union of two SetArguments.">merge</a>(&amp;N, e);
<a name="l00063"></a>00063                 ANC = C.<a class="code" href="classSetArguments.html#a8f48fd9f7b627db762d4fc2621160853" title="Get the arguments in the caller set which are attacked by at least one node in attackers.">getSubsetAttackedBy</a>(&amp;N);
<a name="l00064"></a>00064                 ANI = I-&gt;<a class="code" href="classSetArguments.html#a8f48fd9f7b627db762d4fc2621160853" title="Get the arguments in the caller set which are attacked by at least one node in attackers.">getSubsetAttackedBy</a>(&amp;N);
<a name="l00065"></a>00065 
<a name="l00066"></a>00066                 N.<a class="code" href="classSetArguments.html#a1b532abb70dde9aa99148be16ed59af1" title="Perform the union of two SetArguments.">merge</a>(ANC, &amp;Cunion);
<a name="l00067"></a>00067                 N.<a class="code" href="classSetArguments.html#a1b532abb70dde9aa99148be16ed59af1" title="Perform the union of two SetArguments.">merge</a>(ANI, &amp;Iunion);
<a name="l00068"></a>00068                 <span class="comment">//ANC must be freed</span>
<a name="l00069"></a>00069                 <span class="keyword">delete</span> ANC;
<a name="l00070"></a>00070                 <span class="keyword">delete</span> ANI;
<a name="l00071"></a>00071                 C.<a class="code" href="classSetArguments.html#a80e626de391cabfc0a20da509c328055" title="Setmisun.">setminus</a>(&amp;Cunion, &amp;C);
<a name="l00072"></a>00072                 I-&gt;<a class="code" href="classSetArguments.html#a80e626de391cabfc0a20da509c328055" title="Setmisun.">setminus</a>(&amp;Iunion, I);
<a name="l00073"></a>00073 
<a name="l00074"></a>00074 <span class="preprocessor">                #ifdef DEBUG_GROUNDED</span>
<a name="l00075"></a>00075 <span class="preprocessor"></span>                        cout &lt;&lt; <span class="stringliteral">&quot;************FINE ITERAZIONE GROUNDED************&quot;</span> &lt;&lt; endl;
<a name="l00076"></a>00076                         cout &lt;&lt; <span class="stringliteral">&quot;e dopo merge: &quot;</span>&lt;&lt; *e &lt;&lt; endl;
<a name="l00077"></a>00077                         cout &lt;&lt; <span class="stringliteral">&quot;ANC: &quot;</span> &lt;&lt; ANC &lt;&lt; endl;
<a name="l00078"></a>00078                         cout &lt;&lt; <span class="stringliteral">&quot;ANI: &quot;</span> &lt;&lt; ANI &lt;&lt; endl;
<a name="l00079"></a>00079                         cout &lt;&lt; <span class="stringliteral">&quot;nuovo C&quot;</span> &lt;&lt; C &lt;&lt; endl;
<a name="l00080"></a>00080                         cout &lt;&lt; <span class="stringliteral">&quot;nuovo I&quot;</span> &lt;&lt; *I&lt;&lt; endl;
<a name="l00081"></a>00081 <span class="preprocessor">                #endif</span>
<a name="l00082"></a>00082 <span class="preprocessor"></span>        }
<a name="l00083"></a>00083 <span class="preprocessor">        #ifdef DEBUG_GROUNDED</span>
<a name="l00084"></a>00084 <span class="preprocessor"></span>                cout &lt;&lt; <span class="stringliteral">&quot;alla fine di grounded:e:\t&quot;</span> &lt;&lt; *e &lt;&lt; endl;
<a name="l00085"></a>00085                 cout &lt;&lt; <span class="stringliteral">&quot;alla fine di grounded:I:\t&quot;</span> &lt;&lt; *I &lt;&lt; endl;
<a name="l00086"></a>00086 <span class="preprocessor">        #endif</span>
<a name="l00087"></a>00087 <span class="preprocessor"></span>}
<a name="l00088"></a>00088 
<a name="l00104"></a><a class="code" href="classGrounded.html#a20b4011b5fa1a6f423708f8d293b7630">00104</a> <span class="keywordtype">bool</span> <a class="code" href="classGrounded.html#a20b4011b5fa1a6f423708f8d293b7630" title="computes N and verify that it is empty">Grounded::isNempty</a>(<a class="code" href="classSetArguments.html" title="Class encompassing a set of arguments.">SetArguments</a>* C, <a class="code" href="classSetArguments.html" title="Class encompassing a set of arguments.">SetArguments</a>* I, <a class="code" href="classSetArguments.html" title="Class encompassing a set of arguments.">SetArguments</a>* N) {
<a name="l00105"></a>00105         <span class="comment">//N= tutti e soli i nodi di C che non sono attaccati da alcun nodo in I</span>
<a name="l00106"></a>00106 
<a name="l00107"></a>00107         *N = <a class="code" href="classSetArguments.html" title="Class encompassing a set of arguments.">SetArguments</a>();
<a name="l00108"></a>00108 
<a name="l00109"></a>00109         <a class="code" href="classGrounded.html#ac70689c14c7e88b07598e0d66c0eda56" title="computes the set where all the nodes in it are in C and are not attacked by no nodes in I...">Grounded::computeNSet</a>(C, I, N);
<a name="l00110"></a>00110 <span class="preprocessor">        #ifdef DEBUG_GROUNDED</span>
<a name="l00111"></a>00111 <span class="preprocessor"></span>                cout &lt;&lt; <span class="stringliteral">&quot;N: &quot;</span> &lt;&lt; N &lt;&lt; endl;
<a name="l00112"></a>00112 <span class="preprocessor">        #endif</span>
<a name="l00113"></a>00113 <span class="preprocessor"></span>        <span class="keywordflow">return</span> N-&gt;<a class="code" href="classSetArguments.html#a91e548daa6d0859946c8604b1ebb8c5a" title="Check wether or not this set is empty.">empty</a>();
<a name="l00114"></a>00114 }
<a name="l00115"></a>00115 <span class="comment">// subset dei soli nodi di C NON attaccati da nodi in I</span>
<a name="l00116"></a>00116 
<a name="l00168"></a><a class="code" href="classGrounded.html#ac70689c14c7e88b07598e0d66c0eda56">00168</a> <span class="keywordtype">void</span> <a class="code" href="classGrounded.html#ac70689c14c7e88b07598e0d66c0eda56" title="computes the set where all the nodes in it are in C and are not attacked by no nodes in I...">Grounded::computeNSet</a>(<a class="code" href="classSetArguments.html" title="Class encompassing a set of arguments.">SetArguments</a>* C, <a class="code" href="classSetArguments.html" title="Class encompassing a set of arguments.">SetArguments</a>* I, <a class="code" href="classSetArguments.html" title="Class encompassing a set of arguments.">SetArguments</a>* N) {
<a name="l00169"></a>00169         <a class="code" href="classSetArguments.html" title="Class encompassing a set of arguments.">SetArguments</a>* nodeAttackers;
<a name="l00170"></a>00170 
<a name="l00171"></a>00171         <span class="comment">/* for each node in C, computes the nodes which attack it:</span>
<a name="l00172"></a>00172 <span class="comment">                   if there are none, add the node analysed in N</span>
<a name="l00173"></a>00173 <span class="comment">                   continue otherwise */</span>
<a name="l00174"></a>00174         <span class="keywordflow">for</span> (<a class="code" href="classSetArgumentsIterator.html" title="Class defining a const iterator for the elements of a set of arguments.">SetArgumentsIterator</a> it=C-&gt;<a class="code" href="classSetArguments.html#aaee058feaed861edf27739fa04f374ef" title="Begin of the iterator for this set of arguments.">begin</a>(); it!=C-&gt;<a class="code" href="classSetArguments.html#a551272d71c803f64efc155b04f41e775" title="End of the iterator for this set of arguments.">end</a>(); it++){
<a name="l00175"></a>00175                 nodeAttackers= <span class="keyword">new</span> <a class="code" href="classSetArguments.html" title="Class encompassing a set of arguments.">SetArguments</a>();
<a name="l00176"></a>00176                 (*it)-&gt;get_attackers()-&gt;intersect(I,nodeAttackers);
<a name="l00177"></a>00177                 <span class="keywordflow">if</span> (nodeAttackers-&gt;<a class="code" href="classSetArguments.html#a91e548daa6d0859946c8604b1ebb8c5a" title="Check wether or not this set is empty.">empty</a>()==<span class="keyword">true</span>)
<a name="l00178"></a>00178                         N-&gt;<a class="code" href="classSetArguments.html#a989d8986ecf49baa0dc982766c0a5df4" title="Add an argument to the set.">add_Argument</a>(*it);
<a name="l00179"></a>00179                 <span class="keyword">delete</span> nodeAttackers;
<a name="l00180"></a>00180         }
<a name="l00181"></a>00181 }
<a name="l00182"></a>00182 
<a name="l00183"></a>00183 Grounded::~Grounded() {
<a name="l00184"></a>00184 }
<a name="l00185"></a>00185 
</pre></div></div><!-- contents -->
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="Grounded_8cpp.html">Grounded.cpp</a>      </li>

    <li class="footer">Generated on Fri Jan 17 2014 11:47:51 for SemOpt by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.6.1 </li>
   </ul>
 </div>


</body>
</html>
